const { sequelize, DataTypes } = require('sequelize');

const seq = require("../db/index");
const { ISFORCE } = require("../utils/dot");

// 参数：姓名，性别，出生年月，手机号，政治面貌，学历学校，所在部门，职位，入职时间，目前状态
const peopleModel = seq.define('People', {
    name: {
        type: DataTypes.STRING,
        allowNull: false, 
        comment: "姓名"
    },
    sex: {
        type: DataTypes.STRING,
        allowNull: false,
        comment: "性别"
    },
    birth: {
        type: DataTypes.DATE,
        allowNull: false,
        comment: "出生年月"
    },
    phone: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true,
        comment: "手机号"
    },
    political: {
        type: DataTypes.STRING,
        allowNull: false,
        comment: "政治面貌"
    },
    education: {
        type: DataTypes.STRING,
        allowNull: false,
        comment: "学历学校"
    },
    department: {
        type: DataTypes.STRING,
        comment: "所在部门"
    },
    position: {
        type: DataTypes.STRING,
        comment: "职位"
    },
    entryTime: {
        type: DataTypes.DATE,
        comment: "入职时间"
    },
    status: {
        type: DataTypes.STRING,
        comment: "目前状态"
    },
    isDelete: {
        type: DataTypes.BOOLEAN,
        defaultValue: false,
        comment: "是否删除"
    }
}, {});

if (ISFORCE == "true") {
    peopleModel.sync({ force: true });
}
 
module.exports = peopleModel;